
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title></title>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link rel="stylesheet" href="/lib/layui/layui/css/common.css?v=20190802">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="../../js/jquery/jquery-1.9.1.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019072018:09" type="text/javascript" charset="utf-8"></script>
</head>
<body>

<button type="button" class="layui-btn" id="but_chose">
    <i class="layui-icon">&#xe67c;</i>选择文件
</button>
<input  id="s_pmt_dw" style="width:190px">
<button type="button" class="layui-btn" id="but_upload">
    <i class="layui-icon">&#xe67c;</i>文件上传
</button>
<div class="layui-upload-list" id="demo2"></div>

<script src="/static/build/layui.js"></script>
<script>
    layui.use('upload', function(){
        var upload = layui.upload;

        //执行实例
        var uploadInst = upload.render({
            elem: '#but_chose' //绑定元素
            ,url: '../upload?module=equip' //上传接口
            ,accept:'file'
            ,auto:false
            ,bindAction:'#but_upload'
            ,multiple:true
            ,choose: function(obj){
                obj.preview(function (index,file,result) {
                    $('#demo2').append('<img name = "s_pmt_dw" style="width: 120px; height: 150px; margin-left: 16px;" src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
                    $('#s_pmt_dw').val(file.name);//显示文件名
                });
            }
            ,before: function(obj){
                //请求异常回调
                return flag;
                layer.load();//长传loading
            }
            ,done:function (res) {
                $('#fileTips').text('((文件未选择))');//显示文件名
                flag=false;
                layer.close(layer.load());
            }
            ,error:function () {
                layer.close(layer.load());
            }
        });
    });
</script>
</body>
</html>